/***************************************************************************
 *   KShootout - online shootout card game.                                *
 *   Copyright (C) 2008, 2009  MacJariel                                   *
 *                                                                         *
 *   KShootout is free software: you can redistribute it and/or modify     *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation, either version 3 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   KShootout is distributed in the hope that it will be useful,          *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with KShootout.  If not, see <http://www.gnu.org/licenses/>.    *
 ***************************************************************************/
#ifndef __APPLICATION_H__
#define __APPLICATION_H__

#include "gametypes.h"
#include <QApplication>

namespace client
{
    class MainWindow;
    class ServerConnection;
    class Game;

    class Application: public QApplication
    {
    Q_OBJECT;
    public:
        /// Mode of the application
        enum Mode {
            DefaultMode = 0,
            ServerMode,
            GameMode
        };

        Application(int argc, char* argv[]);
        virtual ~Application();

        Mode mode() const {
            return m_mode;
        }

        static Application* instance();
        static MainWindow* mainWindow();

    private slots:
        void onServerEvent(const ServerEventDataPtr&);

    signals:
        void modeChanged();
        void stateChanged();

    private:
        MainWindow*         mp_mainWindow;
        ServerConnection*   mp_serverConnection;
        Game*               mp_game;
        Mode                m_mode;
    };

    inline Application* Application::instance()
    {
        return static_cast<Application*>(QApplication::instance());
    }

    inline MainWindow* Application::mainWindow()
    {
        return Application::instance()->mainWindow();
    }
}

#endif // __APPLICATION_H__
